import unittest
import requests
from crm_token import token

class MyTestCase(unittest.TestCase):
    def test_userreduce(self):
        '''获取用户个人中心页面的个人基本信息'''
        head={'Admin-Token':token()}
        reduce=requests.post('http://182.92.197.48:8080/system/user/queryLoginUser',headers=head,timeout=3)
        # print(reduce.json())
        back=reduce.json()
        # 下边开始断言
        self.assertEqual(back['data']['username'],'19999999999')
    def test_PageList(self):
        '''获取线索列表接口测试'''
        date_02={"page":1,"limit":15,"search":"","type":1}
        head_02={'Content-Type':'application/json','Admin-Token':token()}
        xiansuo=requests.post('http://182.92.197.48:8080/CrmLeads/queryPageList',json=date_02,headers=head_02,timeout=3)
        # print(xiansuo.json())
        back_02=xiansuo.json()
        # 下面开始断言
        self.assertEqual(back_02['code'],0)
    def test_CustomerList(self):
        '''客户列表的搜索测试'''
        date_03={"page":1,"limit":100,"search":"阴浩","type":2}
        head_03 = {'Content-Type': 'application/json', 'Admin-Token': token()}
        search=requests.post('http://182.92.197.48:8080/CrmCustomer/queryPageList',json=date_03,headers=head_03,timeout=3)
        # print(search.json())
        back_03=search.json()
        #下边开始断言
        self.assertEqual(back_03['data']['list'][0]['createUserName'],'阴浩')
    def test_addtask(self):
        '''新建任务的测试'''
        date_04={'name':'yh_add_task'}
        head_04={'Content-Type':'application/x-www-form-urlencoded','Admin-Token': token()}
        addtask=requests.post('http://182.92.197.48:8080/task/setTask',data=date_04,headers=head_04,timeout=4)
        # print(addtask.json())
        back_04=addtask.json()
        #下面开始断言
        self.assertEqual(back_04['code'],0)

if __name__ == '__main__':
    unittest.main()
